/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved.
 */

package com.baidu.process.cloud.apigateway.sdk.utils;

import com.baidu.process.cloud.sdk.http.HttpMethodName;

import org.apache.http.client.methods.HttpRequestBase;

import java.io.InputStream;
import java.util.Map;

public abstract class AccessService {
    protected String ak;
    protected String sk;
    protected String messageDigestAlgorithm = "SDK-HMAC-SHA256";
    public AccessService(String ak, String sk) {
        this.ak = ak;
        this.sk = sk;
    }

    public AccessService(String ak, String sk, String messageDigestAlgorithm) {
        this.ak = ak;
        this.sk = sk;
        this.messageDigestAlgorithm = messageDigestAlgorithm;
    }

    public abstract HttpRequestBase access(String url, Map<String, String> header, InputStream content,
            Long contentLength, HttpMethodName httpMethod) throws Exception;

    public abstract HttpRequestBase access(String url, Map<String, String> header, String content,
            HttpMethodName httpMethod) throws Exception;

    public HttpRequestBase access(String url, Map<String, String> header, HttpMethodName httpMethod) throws Exception {
        return this.access(url, header, null, 0L, httpMethod);
    }

    public HttpRequestBase access(String url, InputStream content, Long contentLength, HttpMethodName httpMethod)
            throws Exception {
        return this.access(url, null, content, contentLength, httpMethod);
    }

    public HttpRequestBase access(String url, HttpMethodName httpMethod) throws Exception {
        return this.access(url, null, null, 0L, httpMethod);
    }

    public String getAk() {
        return ak;
    }

    public void setAk(String ak) {
        this.ak = ak;
    }

    public String getSk() {
        return sk;
    }

    public void setSk(String sk) {
        this.sk = sk;
    }
}
